import React from "react";
import { Button, Modal, Select, Space } from "antd";
import dayjs from "dayjs";
import { mobxState } from "@/data";

/**@description 列表表格字段 */
const getColumns = ({ open = Function, handleDelete = Function, onChangeRole = Function }) => {
    const columns = [
        {
            title: "注册时间",
            key: "createDate",
            dataIndex: "createDate",
            width: 180,
            render: (text) => dayjs(text).format("YYYY-MM-DD HH:mm:ss")
        },
        {
            title: "用户ID",
            key: "userId",
            dataIndex: "userId",
            width: 180,
        },
        {
            title: "姓名",
            key: "userName",
            dataIndex: "userName",
            width: 180,
        },
        {
            title: "归属角色",
            key: "roleName",
            dataIndex: "roleName",
            width: 180,
        },
        {
            title: "状态",
            key: "status",
            dataIndex: "status",
            width: 180,
        },
        {
            title: "操作",
            key: "action",
            dataIndex: "action",
            width: 280,
            render: (text, record) => {
                return (
                    <Space>
                        <Button type="link" onClick={() => {
                            console.log("资料：", record);
                            const { userName, _id, userId } = record;
                            mobxState.onChangeTab({
                                label: userName + "-资料页",
                                key: _id,
                                path: "/systemSeting/userDetail",
                                state: {
                                    userName, _id, userId
                                }
                            })
                        }}>资料详情</Button>
                        <Button
                            type="link"
                            onClick={() => open({ type: "update", record })}
                        >修改</Button>
                        <Button
                            type="link"
                            onClick={() => onChangeRole(record)}
                        >分配角色</Button>
                    </Space>
                )
            }
        }
    ];
    return columns;
}

export default getColumns;